package com.sugree.util;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import org.json.JSONObject;
import org.json.JSONException;

import android.util.Log;

import com.sugree.jibjib.net.Connection;

public class Twitgoo implements Shortener {
	private static final String TAG = "Twitgoo";

	private Connection mConnection;

	public Twitgoo(Connection con) {
		mConnection = con;
	}

	@Override
	public String shorten(String url) throws ApiException {
		try {
			JSONObject jo = mConnection.postTwitgoo(url);
			return jo.getString("mediaurl");
		} catch (IOException e) {
			throw new Shortener.ApiException(e);
		} catch (JSONException e) {
			throw new Shortener.ApiException(e);
		} catch (Exception e) {
			throw new Shortener.ApiException(e);
		}
	}
}
